import renderMarkdown from "./render/markdown.js";
import renderToc from "./render/GHtoc.js";
import eventInit from "./event/jsEvent.js";

import { getContent } from "./communicate/githubPart.js";
import { Version } from "./all.js";
window.Setting = {};

window.onload = async function () {
    // 网页初步加载
    eventInit();
    hljs.initHighlightingOnLoad();

    // 载入 document.json

    let { user, repo, path = "README.md", root = "" } = Object.fromEntries(new URL(location.href).searchParams.entries());

    //重要数据载入window
    window.Setting = { user, repo, path };

    document.head.querySelector("title").innerHTML = repo;

    let text = await getContent(user, repo, path);
    renderMarkdown(text);

    renderToc(user, repo, root);
};
